package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.dao.UserDao;
import com.itheima.pojo.User;
import com.itheima.service.ValidateCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@Service(interfaceClass = ValidateCodeService.class)
@Transactional
public class ValidateCodeServiceImpl implements ValidateCodeService {
    @Autowired
    private UserDao userDao;
    @Override
    public String findByUsername(String name) {
        try {
            //根据用户名查询数据库
            User user = userDao.findByUser(name);
            if (user==null){
                return null;
            }
            return user.getTelephone();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
